package repository

import (
	"context"

	"gitee.com/youkelike/zlog"
	"gitee.com/youkelike/zmigrate/example/interactive/repository/dao"
)

//go:generate mockgen -source=./interactive.go -package=repomocks -destination=mocks/interactive.mock.go InteractiveRepository
type InteractiveRepository interface {
	IncrReadCnt(ctx context.Context,
		biz string, bizId int64) error
	IncrLike(ctx context.Context, biz string, bizId, uid int64) error
}

type ReadCntRepository struct {
	dao dao.InteractiveDAO
	l   zlog.Logger
}

func (c *ReadCntRepository) IncrLike(ctx context.Context, biz string, bizId int64, uid int64) error {
	return c.dao.InsertLikeInfo(ctx, biz, bizId, uid)
}

func (c *ReadCntRepository) IncrReadCnt(ctx context.Context, biz string, bizId int64) error {
	return c.dao.IncrReadCnt(ctx, biz, bizId)
}

func NewInteractiveRepository(dao dao.InteractiveDAO, l zlog.Logger) InteractiveRepository {
	return &ReadCntRepository{
		dao: dao,
		l:   l,
	}
}
